<template>
  <Modal
    id="resourceCheckBoxsDialog"
    v-model="initOption.visible"
    :mask-closable="false"
    width="800">
    <Tree :data="menuList" show-checkbox></Tree>
  </Modal>
</template>
<script>
import {getMenuCTreeInfo} from '@/apis/admin/menu';

export default {
  name: 'menuTreeCheckBoxDialog',
  props: {
    initOption: {
      visible: true,
      title: ''
    }
  },
  data: function data () {
    return {
      menuList: []
    };
  },
  methods: {
    getMenus () {
      getMenuCTreeInfo().then(response => {
        if (response.data.success) {
          this.menuList = response.data.obj;
        } else {
          this.$Modal.error({
            title: '提示',
            content: response.data.msg
          });
        }
      });
    }
  },
  watch: {
    'initOption.visible' (val) {
      if (val) {
        this.getMenus();
      } else {
        this.menuList = [];
      }
    }
  }
};
</script>
<style>
</style>
